import { createRouter, createWebHistory } from "vue-router";

// 静态导入需要用到的组件
import Home from "./pages/Home.vue";
import About from "./pages/About.vue";
import Detail from "./pages/Detail.vue";
import FilmList from "./pages/FilmList.vue";
import FilmInfo from "./pages/FilmInfo.vue";

const router = createRouter({
  history: createWebHistory(),

  // 设置路线，路由规则
  routes: [
    {
      path: "/a",
      redirect: "/film/6641",
    },
    {
      // 命名路由
      name: "index",
      path: "/",
      alias: "/b",
      /**
       * 命名视图，
       *    key - 是一个名字，需要配合 RouterView name 属性使用
       */
      components: {
        left: Home,
        right: About,
        default: FilmList,
      },
    },

    {
      path: "/film/:id",
      name: "film",
      component: FilmInfo,
    },
  ],
});

// 导出路由器
export default router;
